package advance_2;

import java.util.*;

public class MapTest {
    public static void main(String[] args) {
        //二维结构
        Map map = new HashMap();//TreeMap
        map.put("dog", "狗");
        map.put("cat", "猫");
        map.put("yes", "是");
        map.put("sheep", "绵羊");
        map.put("sheep", "山羊");
        map.put(new Dog("小花花"), "jack");
        map.put(new Dog("小黑"), "Lucy");
        map.put(new Dog("哈巴"), "Tony");
        map.put(new Dog("哈巴"), "Jaery");

        System.out.println(map.size());
        System.out.println(map);
        String rtn=(String)map.remove("tiger");
        System.out.println(rtn+"被删除了...");
        System.out.println(">>>>>>>>>>>>>>>>>>");
        Set keys=map.keySet();
        System.out.println("所有的key:"+keys);
        Collection col=map.values();
        System.out.println("所有的value:"+col);
        //Map.entry
        System.out.println(">>>>>>>>>>>迭代>>>>>>>>>>>");
        Iterator ir=keys.iterator();
        while(ir.hasNext()){
            Object key=ir.next();
            Object value=map.get(key);
            System.out.println(key+"="+value);
        }
    }
}
